package cn.jlonely.xyhx.admin.service.impl;

import cn.jlonely.xyhx.admin.mapper.ReviewMapper;
import cn.jlonely.xyhx.pojo.Review;
import cn.jlonely.xyhx.admin.service.ReviewService;
import cn.jlonely.xyhx.pojo.vo.ReviewVo;
import cn.jlonely.xyhx.utils.PageResult;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReviewServiceImpl implements ReviewService {
    @Autowired
    private ReviewMapper reviewMapper;

    @Override
    public PageResult<ReviewVo> getReviewInfo(Integer page, Integer pageSize) {
        PageHelper.startPage(page, pageSize);
        List<ReviewVo> reviews = reviewMapper.getReviewInfo();
        Page<ReviewVo> r = (Page<ReviewVo>) reviews;
        return new PageResult<>(r.getTotal(), r.getResult());
    }

    @Override
    public void updateReviewStatus(Integer id, Integer judgeStatus) {
        reviewMapper.updateReviewStatus(id, judgeStatus);
    }
}
